package com.qxsx.midi.activity.me;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;

import com.qxsx.midi.R;
import com.qxsx.midi.activity.base.BaseActivity;
import com.qxsx.midi.adapter.ApplyAdapter;
import com.qxsx.midi.model.Apply;
import com.qxsx.midi.view.XListView;

import java.util.ArrayList;

/**
 * Created by Joney on 2015/9/9.
 * 申请列表
 */
public class ApplyListActivity extends BaseActivity implements OnClickListener {

    private ApplyAdapter adapter;

    private ArrayList<Apply> lists;

    private XListView lv_apply;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_apply_list);
        setNavBtn(R.mipmap.back, 0);
        setTitle("申请成功");
        findById();
        inItData();
    }

    private void inItData() {

        lists = new ArrayList<>();
        adapter = new ApplyAdapter(ApplyListActivity.this, lists);
        lv_apply.setAdapter(adapter);

        ArrayList<Apply> list = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            Apply apply = new Apply();
            list.add(apply);
        }
        adapter.AddData(list);


    }

    private void findById() {
        lv_apply = (XListView) findViewById(R.id.lv_apply);

    }

    @Override
    protected void onResume() {
        super.onResume();
        lv_apply.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                position = position-1;
                if(position == 0){
                    startActivity(new Intent(ApplyListActivity.this,ApplyImageDetailsActivity.class));

                }else if(position == 1){
                    startActivity(new Intent(ApplyListActivity.this,ApplyMusicDetailsActivity.class));
                }else {
                    startActivity(new Intent(ApplyListActivity.this,ApplyViedoDetailsActivity.class));
                }
            }
        });

    }

    @Override
    protected void HandleTitleBarEvent(TitleBar component, View v) {
        switch (component) {
            case LEFT:
                finish();
                break;
        }

    }

    @Override
    public void onClick(View v) {

    }
}
